package zjh_20230313;

import java.util.Objects;

public class Person02 implements Comparable<Person02>{
    private String name;
    private int age;
    private char gender;

    public Person02(String name, int age, char gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public void setName(String name){
        this.name = name;
    }
    public void setAge(int age){
        this.age = age;
    }
    public void setgender(char gender){
        this.gender = gender;
    }
    public String getName(){
        return this.name;
    }
    public int getAge(){
        return this.age;
    }
    public char getgender(){
        return this.gender;
    }

    public String toString() {
        return "Person { name :" + this.name
                + ", age :" + this.age +
                "gender :" + this.gender + "}";
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null) {
            return false;
        }
        if (o.getClass() != getClass()) {
            return false;
        }
        Person02 p = (Person02) o;
        return p.gender == this.gender && p.age == this.age && Objects.equals(this.getName(),p.getName());
    }

    @Override
    public int compareTo(Person02 o) {
        return this.getAge() - o.getAge();
    }
}
